#include "I2Cdev.h"
#include "Wire.h"
#include "MPU6050.h"

#define B1 A2  // Button 1
#define B2 7
#define B3 8

MPU6050 imu;
int16_t ax, ay, az, gg;

void setup(){
  pinMode(B1,INPUT);digitalWrite(B1,HIGH); //在输入模式下输
  pinMode(B2,INPUT);digitalWrite(B2,HIGH); //出高电平打开内
  pinMode(B3,INPUT);digitalWrite(B3,HIGH); //部上拉电阻
  Wire.begin(); Serial.begin(57600);
  imu.initialize();
}

void loop(){
  delay(50); //避免采样速度太快
  imu.getMotion6(&ax,&ay,&az,&gg,&gg,&gg); //读取加速度
  Serial.print(ax/16384.0);Serial.print(",");
  Serial.print(ay/16384.0);Serial.print(",");
  Serial.print(az/16384.0);Serial.print(",");
  Serial.print(digitalRead(B1));Serial.print(",");
  Serial.print(digitalRead(B2));Serial.print(",");
  Serial.println(digitalRead(B3));  //发送一个新行
}

